import java.util.Arrays;

public class Test {
    public static  void main(String[]args){
        String str="ababc";
        String ret=str.substring(0,3);
        System.out.println(ret);
        String ret2=str.substring(2);
        System.out.println(ret2);
        System.out.println("******************");
        String str2="   dadad      adad    ";
        System.out.println(str2);
        System.out.println(str2.trim());//去掉左右两边空格，中间无法去掉

    }
    public static  void main8(String[]args){
       /* String str="hello abc world";
        String[]ret=str.split(" ",2);
        for(int i=0;i<ret.length;i++)
        {
            System.out.println(ret[i]);
        }*/
       /* String str="192.168.1.1";
        String[]ret=str.split("\\.");
        for(int i=0;i<ret.length;i++)
        {
            System.out.println(ret[i]);
        }*/
       /* String str2="192\\28\\32";
        String[] ret=str2.split("\\\\");
        for(int i=0;i<ret.length;i++)
        {
            System.out.println(ret[i]);
        }*/
      /*  String str="name=zhangsan&age=15";
        String[]ret=str.split("=|&");
        for(int i=0;i<ret.length;i++)
        {
            System.out.println(ret[i]);
        }*/
        String str="name=zhangsan&age=15";
        String[]ret=str.split("&");
        for(int i=0;i<ret.length;i++)
        {
           String str2=ret[i];
           String[]ret2=str2.split("=");
           for(int j=0;j<ret2.length;j++)
           {
               System.out.println(ret2[j]);
           }

        }






    }
    public static  void main7(String[]args){
        String str="ababcccscabab";
        String ret=str.replace("ab","999");
        System.out.println(ret);
        ret=str.replace('a','8');
        System.out.println(ret);
        ret=str.replaceFirst("ab","ppp");
        System.out.println(ret);
        ret=str.replaceAll("ab","123");
        System.out.println(ret);



    }
    public static  void main6(String[]args){
        String s1="hello";
       char []array=s1.toCharArray();
        System.out.println(Arrays.toString(array));
       int abc= array.length;
        char []array2={'a','c','c'};
        String s2=new String(array2);
        System.out.println(s2);
        String s=String.format("%d-%d-%d",2019,9,14);//格式化输出
        System.out.println(s);
    }
    public static  void main5(String[]args){

     /*   String s=String.valueOf(19);
        System.out.println(s);*/
//        int data=Integer.parseInt("19");
        String s1="hello";
        String ret=s1.toUpperCase();
        System.out.println(s1);//转变新的一个对象给到ret
        System.out.println(ret);
        String s2="HEllo";
        ret=s2.toLowerCase();
        System.out.println(s2);
        System.out.println(ret);

    }
    public static  void main4(String[]args){

        String s1="hello";
        String str1="hello";
        for(int i=0;i<str1.length();i++)
        {
            char ch=s1.charAt(i);
            System.out.println(ch);
        }
        String s2="abaab";
//        int index=s1.indexOf('l');
//        int index=s1.indexOf('l',2);
        char ch=s1.charAt(2);
        System.out.println(ch);
//        int index=s2.indexOf("ab");
//        int index=s2.indexOf("ab",3);
        int index=s2.lastIndexOf("ab",0);
        System.out.println(index);
    }
    public static  void main3(String[]args){
        String s1=new String("abc");
        String s2=new String("aBC");
/*        System.out.println(s1==s2);
        System.out.println(s1.equals(s2));*/
        System.out.println(s1.compareTo(s2));
        System.out.println(s1.compareToIgnoreCase(s2));

    }
    public static  void main2(String[]args){
        String s1=new String("hello");
        String s2=new String("world");
        String s3=s1;
        System.out.println(s1.length());
        System.out.println(s2.length());
        System.out.println(s3.length());
        String str4="";
        System.out.println(str4.length());
        System.out.println(str4.isEmpty());
        String str5=null;
//        System.out.println(str5.length());报错，空指针
    }
     public static  void main1(String[]args){

         String str="hello";
         System.out.println(str);

         String str2=new String();
         System.out.println(str2);
         String str3=new String("pppp");
         char[]array={'a','b','c'};
         String str4=new String(array);
         System.out.println(str4);
     }
}
